//package io.github.novaframe.config.metrics;
//
//import com.codahale.metrics.MetricRegistry;
//import io.github.novaframe.config.NovaframeProperties;
//import io.prometheus.client.CollectorRegistry;
//import io.prometheus.client.dropwizard.DropwizardExports;
//import io.prometheus.client.exporter.MetricsServlet;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
//import org.springframework.boot.web.servlet.ServletContextInitializer;
//import org.springframework.context.annotation.Configuration;
//
//import javax.servlet.ServletContext;
//import javax.servlet.ServletException;
//
///**
// * Created by Locki on 8/15/2017.
// */
//@Configuration
//@ConditionalOnClass(CollectorRegistry.class)
//public class PrometheusRegistry implements ServletContextInitializer {
//
//    private final Logger log = LoggerFactory.getLogger(PrometheusRegistry.class);
//
//    private final MetricRegistry metricRegistry;
//
//    private final NovaframeProperties properties;
//
//    public PrometheusRegistry(MetricRegistry metricRegistry, NovaframeProperties properties) {
//        this.metricRegistry = metricRegistry;
//        this.properties = properties;
//    }
//
//    @Override
//    public void onStartup(ServletContext servletContext) throws ServletException {
//        if (properties.getMetrics().getPrometheus().isEnabled()) {
//            String endpoint = properties.getMetrics().getPrometheus().getEndpoint();
//            log.info("Initializing Metrics Prometheus endpoint at {}", endpoint);
//            CollectorRegistry collectorRegistry = new CollectorRegistry();
//            collectorRegistry.register(new DropwizardExports(metricRegistry));
//            servletContext
//                    .addServlet("prometheusMetrics", new MetricsServlet(collectorRegistry))
//                    .addMapping(endpoint);
//        }
//    }
//}
